package main

import "fmt"

// slice切片
// 是一个可以动态扩缩容的数组，使用make初始化（当然可以可以直接声明然后赋值），有copy append函数可以操作slice
// 支持slice[1:4]截取部分值，左闭右开
func main() {
	s := make([]string, 3)
	fmt.Println("emp:", s)

	s[0] = "0"
	s[1] = "1"
	s[2] = "2"
	fmt.Println("set,", s)
	fmt.Println("get,", s[2])
	fmt.Println("len,", len(s))

	s = append(s, "a")
	s = append(s, "b", "c")
	fmt.Println("apd,", s)

	c := make([]string, len(s))
	copy(c, s)
	fmt.Println("copy,", c)

	l := s[1:3]
	fmt.Println("sl1:", l)

	strings := []string{"a", "b", "c"}
	fmt.Println(strings)

	l2 := s[:5]
	fmt.Println("sl2:", l2)

}
